<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>


<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>频道标签管理</title>
<style type="text/css">
    .l-table-edit {font-size: 12px;margin: auto; width:100%; border-collapse:collapse;}
 	.l-table-edit td{ padding:4px;border:1px solid #336699;}
</style>
</head>

	<table  class="l-table-edit">
		<tr>
			<td width=20%>话题标题</td>
			<td width=60%> ${discuss.title} </td>
			<td width=20%>  </td>
		</tr>
		<tr>
			    <td style="color: red;">已有标签</td>
				<td >
					<c:forEach items="${dtsList}" var="dts">
						 <a href="javascript:void(0);"onclick="deltetDts();">${dts.discussName}</a>&nbsp;| 
					</c:forEach> 
				</td>
				<td >  </td>
			</tr>
			<tr>
			    <td style="color: red;">新选择标签</td>
					<td id="tag">
						
					</td>
				<td ><input type="button" value="保存" onclick="baocunTag('${discuss.identifier}')"/> </td>
			</tr>
			
		
		 <c:forEach items="${channel}" var="chel">
			<tr>
				<td > 
					<c:if test="${chel=='c1fd788e-590b-4579-b5ef-d21a9f42c92d'}">怀孕期</c:if>
					 <c:if test="${chel=='5e02f483-87bd-4d77-81d5-a64ecdc877d0'}">0-1岁</c:if>
					<c:if test="${chel=='1d48a3b9-3709-4270-81b5-0267a5b3546f'}">1-3岁</c:if>
					<c:if test="${chel=='b22c5b02-baa2-42de-ac92-09042e8ccfa2'}">3-6岁</c:if>
				</td>
				<td >
						<c:forEach items="${disTagList }" var="tags">
							<c:if test="${tags.channel==chel}">
								   <a href="javascript:void(0);" onclick="disTag('${tags.identifier}','${tags.name}');">${tags.name}</a>&nbsp;| 
							</c:if>
						</c:forEach>
				</td>
				<td >       
				</td>
			</tr>	
		</c:forEach>
	</table>
	<script type="text/javascript">
	function disTag(tagId, tagName) {
		// alert(channel);
		var tagchannel = $("#tag");
			tagchannel.append('<span style="color: red; cursor: pointer; "  tagId="'+tagId+'" class="tags">'
						+ tagName + '</span>&nbsp;| ');
	}
	function baocunTag(did){
		var tagsList = new Array();
		$.ligerDialog.confirm('你真的要更新吗？', function(yes) {
			if (yes) {
				$(".tags").each(function() {
					tagsList.push({
						"discussTag" : $(this).attr("tagId")
					});
				});
				//alert( tagsList);
				$.post("/misc/discuss/baocunTag.htm", {
					did:did,
					tagsList : $.toJSON(tagsList)
				}, function(data) {
					if (data == 'true') {
						$.ligerDialog.success("推送成功！");
						window.location.href = "/misc/discuss/discuss.htm";
					} else {
						alert("失败了，你要联系马克扎克伯格了。");
					}

				});
			}
		});
	}
	</script>
